package cn.duapi.weblauncher;

import java.lang.reflect.Field;

import javax.servlet.UnavailableException;

import org.eclipse.jetty.server.ResourceCache;
import org.eclipse.jetty.servlet.DefaultServlet;

public class QWebDefaultServlet extends DefaultServlet {

	/**
		 * 
		 */
	private static final long serialVersionUID = 1L;

	@Override
	public void init() throws UnavailableException {
		super.init();
		try {
			this.initUseFileMappedBuffer();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void initUseFileMappedBuffer() throws Exception {
		Field field = DefaultServlet.class.getDeclaredField("_cache");
		field.setAccessible(true);
		ResourceCache cache = (ResourceCache) field.get(this);
		cache.setUseFileMappedBuffer(false);
		// System.err.println("field :" + field + " cache:" + cache);
	}
}
